package com.yiyuan.app.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.yiyuan.app.entity.po.MRecordSignPO;
import com.yiyuan.app.mapper.MRecordSignMapper;
import org.springframework.stereotype.Repository;

@Repository
public class MRecordSignDAO extends BaseDAO<MRecordSignMapper, MRecordSignPO> {


    public MRecordSignPO findLatestOne(Long userId, Long prizeId) {
        LambdaQueryWrapper<MRecordSignPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MRecordSignPO::getPrizeId, prizeId);
        queryWrapper.eq(MRecordSignPO::getUserId, userId);
        queryWrapper.last("limit 0,1");
        queryWrapper.orderByDesc(MRecordSignPO::getId);
        return getBaseMapper().selectOne(queryWrapper);
    }
}
